package com.tongji.mapper;


import com.bean.PanDian;
import com.bean.WmsTCrDetails;
import com.bean.WmsTCustomer;
import com.bean.WmsTStore;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PandianMapper {

    //ajax查询客户信息
    @Select("select * from wms_t_customer where custName like ('%${name}%')")
    public List<WmsTCustomer> getCustomer(@Param("name") String name);

    //查询有东西的仓库信息
    @Select("select * from wms_t_store where wms_t_store.storeID in(\n" +
            "select storeID from wms_t_site WHERE wms_t_site.siteID in(\n" +
            "select siteID from wms_t_tray where wms_t_tray.trayState = '1'));")
    public List<WmsTStore> getStore();

    //开始盘点
    @Select("select wms_t_store.storename,wms_t_customer.custname,wms_t_site.sitecode,wms_t_tray.traycode,wms_t_bill_details.detailsgoodsname,wms_t_bill_details.detailsgoodsspec,wms_t_bill_details.detailsgoodsnum,wms_t_bill_details.detailsID from wms_t_customer \n" +
            "left join wms_t_bill on wms_t_customer.custid = wms_t_bill.customerid \n" +
            "left join wms_t_bill_details on wms_t_bill.billid = wms_t_bill_details.billid \n" +
            "left join wms_t_tray on wms_t_bill_details.trayid = wms_t_tray.trayid \n" +
            "left join wms_t_site on wms_t_tray.siteid = wms_t_site.siteid \n" +
            "left join wms_t_store on wms_t_site.storeid = wms_t_store.storeid \n" +
            "where wms_t_customer.custName = #{custName} and wms_t_store.storeid = #{storeid}\n")
    public List<PanDian> getPanDian(@Param("custName") String custid, @Param("storeid") String storeid);

//    //开始盘点
//    public List<PanDian> getPanDian(@Param("custName") String custid, @Param("storeid") String storeid);

    //判断数据是否存在[存在则不重复插入]
    @Select("select * from wms_t_cr_details where chkrptID = #{chkrptID}")
    public List<WmsTCrDetails> getWmsTCrDetails(WmsTCrDetails wmsTCrDetails);

    //插入WmsTCrDetails
    @Insert("insert into wms_t_cr_details (detailsID,chkrptID,detailsGoodsName,detailsSpec,detailsEditTime,detailsIsDel) \n" +
            "values(#{detailsID},#{chkrptID},#{detailsGoodsName},#{detailsSpec},#{detailsEditTime},'0')")
    public void insertWmsTCrDetails(WmsTCrDetails wmsTCrDetails);


}
